<template>
  <view class="hb-cell" @click="onNavigateTo">
     <view class="hb-cell-content" :style="{paddingRight: right +'rpx'}">
       <slot name="left">
         <view class="label">{{label}}</view>
       </slot>
       <slot name="right">
         <view class="right">
           <text class="value">{{value}}</text>
           <image class="arrow" src="~@/static/images/arrow-right-icon.png"></image>
         </view>
       </slot>
     </view>
  </view>
</template>

<script>
export default {
  name: "hb-cell",
  props: {
    label: String,
    url: String,
    right: {
      default: 0,
      type: [String, Number]
    },
    type: {
      default: 'navigate',
      type: String
    },
    value: String
  },
  methods: {
    onNavigateTo() {
      // 页面跳转
      if (this.url) {
        if (this.type == 'navigate') {
          uni.navigateTo({
            url: this.url
          });
        } else {
          uni.switchTab({
            url: this.url
          });
        }
      } else {
        this.$emit('click');
      }
    }
  }
}
</script>

<style scoped lang="scss">
.hb-cell {
  width: 100%;
  box-sizing: border-box;
  .hb-cell-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 32rpx 0;
    padding-right: 32rpx;
    border-top: 1PX solid #f5f5f5;
    box-sizing: border-box;
    .right {
      display: flex;
      align-items: center;
    }
    .label {
      display: block;
      color: $hb-title-color;
      font-size: 28rpx;
    }
    .value {
      color: $uni-text-color-grey;
      font-size: 28rpx;
    }
    .arrow {
      display: block;
      width: 40rpx;
      height: 40rpx;
    }
  }
}
</style>
